﻿/*----------------------------------------------------------------------------------------
*
*  Copyright 2019, Gao Hai Hui, <fromzeropoint@126.com>.  All rights reserved.
*  https://gitee.com/helloworldghh/xoskit.git
*  Use of this source code is governed by a MIT license
*  that can be found in the License file.
*
----------------------------------------------------------------------------------------*/
#include "../import/head.h"
#include "../impl/head.h"
#include "sys_data.h"

///////////////////////////////////////////////////////////////////////////////////////////////////

namespace xos_odbc
{

    sys_data::sys_data( xos_container::i_container * pContainer ) : m_pContainer( pContainer )
    {
        m_pTime = 0;
    }

    sys_data::~sys_data()
    {
    }

    int sys_data::init()
    {
        int ret = 0;

        if( 0 == ret )
        {
            ret = m_pContainer->xos()->create(xos::i_xos::XOS_OBJ_TIME, ( void ** )&m_pTime);
        }

        if( 0 == ret )
        {
            ret = odbc_fields::init_all();
        }

        if( 0 == ret )
        {
            ret = odbc_field::init_all();
        }

		if( 0 == ret )
		{
			ret = odbc_desc::init_all();
		}

		if( 0 == ret )
		{
            ret = odbc_stmt::init_all();
		}

		if( 0 == ret )
		{
            ret = odbc_dbc::init_all();
		}

        return ret;
    }

    int sys_data::term()
    {
        int ret = 0;

        odbc_fields::term_all();
        odbc_field::term_all();
        odbc_desc::term_all();
        odbc_stmt::term_all();
        odbc_dbc::term_all();
        
		xos_stl::release_interface( m_pTime );

        return ret;
    }

} // xos_odbc
